function lock(fn) {
  let funs = [];

  async function t(...args) {
    funs.push(args);
  }

  setInterval(async () => {
    let args = funs.shift();
    if (args) {
      await fn.apply(this, args);
    }
  }, 1000);

  return t;
}

export default { lock };
